package com.lfy.kcat.content.controller.ai.controller;

import org.springframework.ai.moderation.Generation;
import org.springframework.ai.moderation.ModerationPrompt;
import org.springframework.ai.moderation.ModerationResponse;
import org.springframework.ai.openai.OpenAiModerationModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.*;

@RequestMapping("/openai")
@RestController
public class ModerationController {
    @Autowired
    private OpenAiModerationModel openAiModerationModel;
    @GetMapping("/moderation")
    public Generation moderation(@RequestParam("msg") String message){
        ModerationPrompt moderationPrompt = new ModerationPrompt(message);
        ModerationResponse call = openAiModerationModel.call(moderationPrompt);
        return call.getResult();
    }
}
